;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Evil: Vim like keybinds ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Docs:
(use-package evil
  :ensure t
  :init
  (setq evil-want-integration t) ;; This is optional since it's already set to t by default.
  (setq evil-want-keybinding nil)
  :config
  (require 'evil)
  (evil-mode t)
  (evil-set-leader 'normal (kbd "SPC"))
  (evil-define-key nil evil-normal-state-map
    (kbd "s")   'evil-write
    (kbd "C-s") 'evil-write
    (kbd "C-e") 'eval-buffer
    (kbd "C-l") (lambda () (interactive) (tabnext))
    (kbd "C-h") (lambda () (interactive) (tabprevious))
    (kbd "C-t") (lambda () (interactive) (tabnew))
    (kbd "C-+") 'text-scale-increase
    (kbd "C--") 'text-scale-decrease
    (kbd "C-C") 'compile
    (kbd "<leader>s") 'split-window-horizontally
    (kbd "<leader>v") 'split-window-vertically
    (kbd "<leader>f") 'neotree-toggle
    (kbd "<leader>t") (lambda () (interactive) (split-window-vertically) (windmove-down) (term "zsh")) ; Create a terminal in current directory, FIXME: why doesn't window resize work?
    (kbd "<leader>h") 'windmove-left
    (kbd "<leader>j") 'windmove-down
    (kbd "<leader>k") 'windmove-up
    (kbd "<leader>l") 'windmove-right
    (kbd "<leader>p") 'projectile-command-map)
  (evil-define-key nil evil-insert-state-map
    (kbd "C-s") 'evil-write
    (kbd "C-c") 'evil-normal-state
    (kbd "C-+") 'text-scale-increase
    (kbd "C--") 'text-scale-decrease)
  (evil-define-key 'normal neotree-mode-map
    (kbd "TAB") 'neotree-enter
    (kbd "RET") 'neotree-enter
    (kbd "ESC") 'neotree-hide
    (kbd "r") 'neotree-refresh
    (kbd "A") 'neotree-stretch-toggle
    (kbd "H") 'neotree-hidden-file-toggle
    (kbd "F") 'neotree-create-node
    (kbd "DEL") 'neotree-delete-node
    (kbd "C-+") 'text-scale-increase
    (kbd "C--") 'text-scale-decrease
    (kbd "<leader>r") 'neotree-rename-node
    (kbd "<leader>h") 'windmove-left
    (kbd "<leader>j") 'windmove-down
    (kbd "<leader>k") 'windmove-up
    (kbd "<leader>l") 'windmove-right)
  (use-package evil-collection
   :ensure t 
   :config (evil-collection-init)))

